Managing Code Formatting

The Code Editor gives you the ability to format your code with options such as indenting, hiding text, displaying URLs, and so forth. The language engine also provides features to auto-format your code as you type through Smart Indenting.

Indenting

You can choose three different styles of text indenting. You can also specify how many spaces compose a single indentation or tab, and whether the Editor uses tabs or space characters when indenting.

To choose an indention style

  1. On the Tools menu, click Options.
  2. Click Text Editor.
  3. Select the folder for your language, for example, HTML, or select All Languages to affect indenting settings for all languages.
  4. Click Tabs.
  5. Select one of the options under Indenting and click OK:

To change indent tab settings

  1. On the Tools menu, click Options.
  2. Click Text Editor.
  3. Select the folder for your language, for example, HTML, or select All Languages to affect indenting settings for all languages.
  4. Click Tabs.
  5. To specify that tab characters are used in tab and indent operations, select Keep Tabs. To specify that space characters are used, select Insert Spaces.

    If you selected Insert Spaces, you can enter the number of space characters each tab or indent represents under Tab Size or Indent Size respectively.

To indent code

  1. Select the text you want to indent.
  2. Click the TAB key, or click Indent .

To unindent code

  1. Select the text you want to unindent.
  2. Press SHIFT+TAB key, or click Unindent .

To automatically indent all of your code

  1. In Tools, Options, select Text Editor, All Languages, Tabs, and then select Smart from the Indenting group box.
  2. To select this option on a per-language basis, select Smart in the appropriate folder, starting by selecting Options from the Tools menu.

To automatically indent selected code

  1. Select the text you want to automatically indent.
  2. Click Format Selection in Edit, Advanced, or press CTRL+K, CTRL+F.

    Format Selection applies the smart indenting rules for the language in which you are programming to the selected text.

You can specify size of the tabs and the indents and whether or not the tab characters are converted to spaces.

To convert white space to tabs and vice versa

  1. Select the text whose white space (that is, the spaces between the characters) you want to convert from spaces to tabs.
  2. In Edit, Advanced, click Tabify Selection.
  3. To convert tabs to spaces, in Edit, Advanced, click Untabify Selection.

The functionality of these commands depends on the tab settings in Tools, Options, Text Editor, Tabs. For example, if the tab setting is four, Tabify Selection creates a tab for every four contiguous spaces, and Untabify Selection creates four spaces for every tab.

Hiding Text

By default, all text is displayed in the Code Editor, but in some circumstances you can hide the code from view. There are two different types of hidden text:

Converting Text to Upper and Lower Case

You can use commands to convert text to all upper or lower case.

To switch text to upper or lower case

  1. Select the text you want to convert.
  2. To convert text to upper case, click CTRL+SHIFT+U, or click Make Uppercase in Edit, Advanced.
  3. To convert text to lower case, click CTRL+U, or click Make Lowercase in Edit, Advanced.

The case conversion commands do not affect the case of intrinsic commands.

Displaying and Linking to URLs

You can create and display active URLs (Uniform Resource Locators) in your code. You can then click the link and be taken to the web page in a browser. By default, the URLs:

To display a clickable URL

  1. On the Tools menu, click Options.
  2. Click Text Editor.
  3. To change the option for only one language, click that language and then click General. To change the option for all languages, click All Languages and then click General.
  4. Under Display, select Enable single-click URL navigation.

    Note   If you turn this option off, you can still open a valid internet site by choosing the Open URL command from the Code Editor's context menu.